package com.coolbi.onsupai.core.biz.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import com.coolbi.onsupai.core.biz.CreditBiz;
import com.coolbi.onsupai.core.dao.CreditDao;
import com.coolbi.onsupai.core.entity.Credit;
import com.coolbi.onsupai.core.exception.ServiceException;

public class CreditBizImpl implements CreditBiz {
	
	@Autowired
	private CreditDao creditDao;

	public void setCreditDao(CreditDao creditDao) {
		this.creditDao = creditDao;
	}

	@Override
	public Credit save(Credit obj) {
		try {
			creditDao.save(obj);
		} catch (Exception e) {
			throw new ServiceException("添加会员卡积分发生错误！", e);
		}
		return obj;
	}

	@Override
	public void delete(long id) {
		try{
			creditDao.delete(id);
		}catch(Exception e){
			
			throw new ServiceException("删除会员卡积分发生错误！", e);
		}
	}

	@Override
	public void update(Credit obj) {
		try{
			creditDao.update(obj);
		}catch(Exception e){
			
			throw new ServiceException("更新会员卡积分发生错误！", e);
		}
	}

	@Override
	public Credit get(long id) {
		return creditDao.get(id);
	}

	@Override
	public List<Credit> list() {
		return creditDao.list();
	}

	@Override
	public List<Credit> listByPage(int offset, int limit) {
		
		return creditDao.listByPage(offset, limit);
	}

	@Override
	public List<Credit> find(Map<String, Object> parameter) {
		return creditDao.find(parameter);
	}

	@Override
	public List<Credit> findByPage(Map<String, Object> parameter, int offset,
			int limit) {
		return creditDao.findByPage(parameter, offset, limit);
	}

	@Override
	public List<Credit> search(Map<String, Object> parameter, int offset,
			int limit) {
		return creditDao.search(parameter, offset, limit);
	}

	@Override
	public int count() {
		return creditDao.count();
	}

	@Override
	public int countByKeyWord(Map<String, Object> parameter) {
		return creditDao.countByKeyWord(parameter);
	}

	@Override
	public int count(Map<String, Object> parameter) {
		return creditDao.count(parameter);
	}

}
